;var express = require('express');
var url = require('url')

var app = new express()


/***
 *    request   ---->  middleware -----> router
 *           browser----      m       <----response
 * */

var logger = function (req,res,next) {

    var urlObj = url.parse(req.url,true);
    console.log("the current url is :" + urlObj.pathname);
    next();
}

app.use(logger);

app.get('/test',function (req,res) {
    res.send('test');
})


app.get('/list',function (req,res) {
    res.send('list');
})

var server  =app.listen(3000,'localhost',function () {
    var host = server.address().address;
    var port= server.address().port;

    console.log("the server is running on http:// %s:%s",host,port);
})

